<template>
	<view class="content">
		<view class="logo">

		</view>
		<view class="chengji-box">
			<text class="chengji">{{chengji}}分</text>
			<text class="shijian">{{shijian}}秒</text>
		</view>
		<!-- <button type="primary" class="gotopaihang" @click="gotopaihang">排行榜</button> -->
		<view class="gotopaihang" @click="gotopaihang">
			排行榜
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chengji: 0,
				shijian: 0
			}
		},
		onShow() {
			if (!uni.getStorageSync('USER')) {
				uni.navigateTo({
					url: '../index/index'
				})
			}
			this.chengji = uni.getStorageSync('ZONGFEN')
			this.shijian = uni.getStorageSync('JISHIQI')
			this.updataChengji()
			let arr = [{
					time: 100,
					fen: 80
				},
				{
					time: 30,
					fen: 80
				}, {
					time: 50,
					fen: 90
				}, {
					time: 50,
					fen: 10
				}, {
					time: 40,
					fen: 70
				},
			]
			/* arr.sort((a, b) => {
				if (a.fen >= b.fen) {
					return -1;
				} else if (a.fen < b.fen) {
					return 1;
				} else {
					return a.time - b.time;
				}
			});
			console.log('array', arr); */
		},
		methods: {
			updataChengji() {
				let user = uni.getStorageSync('USER')
				uniCloud.callFunction({
					name: 'tijiao-chengji',
					data: {
						id: user._id,
						zongfen: this.chengji,
						shijian: this.shijian
					}
				}).then(res => {
					console.log(res)
				})
			},
			gotopaihang() {
				uni.navigateTo({
					url: '../paihang/paihang'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: url('@/static/bg.png') no-repeat center top;
		background-size: 100% 100%;
		// height: 1624rpx;
		background-attachment: fixed;
	}

	.chengji-box {
		width: 566rpx;
		height: 900rpx;
		background: url('@/static/chengji.png') no-repeat center center;
		background-size: 100% 100%;
		margin-top: 132rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.chengji {
		font-size: 38px;
		line-height: 38px;
		color: #e60412;
		font-weight: bold;
		margin-top: 516rpx;
	}

	.shijian {
		font-size: 38px;
		line-height: 38px;
		color: #e60412;
		font-weight: bold;
		margin-top: 140rpx;
	}

	.gotopaihang {
		margin-top: 30rpx;
		width: 324rpx;
		height: 80rpx;
		background: url('@/static/xuanzhong-btn.png') no-repeat center center;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #fff;
	}
</style>
